<?php

namespace Taglib;

use Think\Template\TagLib;

class Test extends TagLib{
    protected $tags = array(
        'art' => array('attr'=>'blog_id,value,id'),
    );
    
    public function _art($attr,$content){
        
        $id = $attr['blog_id'];
        
        $blog = M('blog')->find($id);
        
        $value = $this->autoBuildVar($attr['value']);
        $id = !empty($this->autoBuildVar($attr['id'])) ? $this->autoBuildVar($attr['id']) : '$v';
        
        $html = '<?php ';
        
        $html .= 'foreach('.$value.' as '.$id.'):';
        $html .= '?>';
        $html .= $content;
        $html .= '<?php endforeach;?>';
        
        return $html;die;
    }
}
